package com.yizhang.pattern.chain;


/**
 * @Author: yi.zhang
 * @CreateTime: 2025-08-22 15:49:28
 * @Description:
 */
public class MemberService {
    public void login(String userName, String password) {
        Handler<Member> checkMemberHandler = new CheckMemberHandler();
        Handler<Member> loginHandler = new LoginHandler();
        Handler<Member> authHandler = new AuthHandler();
//        checkMemberHandler.setNext(loginHandler);
//        loginHandler.setNext(authHandler);
//        checkMemberHandler.handle(new Member(userName, password));

        Handler.Builder<Member> builder = new Handler.Builder<>();
        Handler<Member> handler = builder.addHandler(checkMemberHandler)
                .addHandler(loginHandler)
                .addHandler(authHandler)
                .build();
        handler.handle(new Member(userName, password));
    }
}
